from django.shortcuts import render

# Create your views here.
# 提供 get 和 delete 方法，可以获取和删除一条已存在数据
from rest_framework.generics import *
#提供 get、put、patch 方法，可以获取一条数据详情，也可以更新一条数据
from rest_framework.generics import RetrieveUpdateAPIView
from .serializers import *
from .models import *


class DepRetrieveDestroyView(ListCreateAPIView):
    queryset = Department.objects.all()
    serializer_class = DepartmentSerializer

class DutyView(ListCreateAPIView):
    queryset = Duty.objects.all()
    serializer_class = DutySerializer

class StaffAPIView(RetrieveUpdateAPIView):
    lookup_field = 'pk'  # 过滤的orm参数
    lookup_url_kwarg = 'pk'
    queryset = Staff.objects.all()
    serializer_class = StaffSerializer
class StaffsView(ListCreateAPIView):
    queryset = Staff.objects.all()
    serializer_class = StaffSerializer